package com.wy.blocking_queue_impl;

import java.util.Scanner;

/**
 * @author 美女
 * @date 2022/05/02 15:45
 **/
public class Main {
    static MyArrayBlockingQueue queue=new MyArrayBlockingQueue(3);
    static class MyThread extends Thread{
        @Override
        public void run() {
            Scanner scanner=new Scanner(System.in);
            long e=scanner.nextLong();
            try {
                queue.put(e);
            } catch (InterruptedException ex) {
                ex.printStackTrace();
            }
        }
    }
    public static void main(String[] args) throws InterruptedException {
        MyThread t=new MyThread();
        t.start();
        long take= queue.take();
        System.out.println(take);
    }
}
//子线程等输入，获取到输入就可以放入到队列中
//主线程take()处等放入东西
//只要子线程输入元素，主线程就能拿取到元素打印了
//由于消费者阻塞，生产者唤醒的过程